home *** CD-ROM | disk | FTP | other *** search
/ HyperLib 1997 Winter - Disc 1 / HYPERLIB-1997-Winter-CD1.ISO.7z / HYPERLIB-1997-Winter-CD1.ISO / オンラインウェア / COM / ProTERM Mac1.2a.sit / ProTERM Mac1.2a / Macros / Resident Macros 1201 < prev    next >
Text File  |  1996-07-24  |  10KB  |  520 lines

  1. /*************************************
  2.  *                                   *
  3.  *  ProTERM/Mac Resident Macro File  *
  4.  *                                   *
  5.  *   Version 1201  Updated 7/14/96   *
  6.  *                                   *
  7.  *************************************/
  8.  
  9. /*
  10. This file is periodically updated by InTrec Software. As such, modifications to this file are not advised (because it becomes very difficult to move your changes to new versions of this file). Instead, make your changes to the Resident User # (where # is a number) file instead. That way, even if you get an updated version of Resident Macros, your own personal macros remain unchanged within the Resident User # file. Note that these directions supercede those given in the Macros chapter of the manual which advises changing the Resident Macros file directly.
  11.  
  12. The Resident User # files have precedence over the Resident Macros file. Therefore, if you define duplicate routines or variables in the Resident User # files, they will be used instead of those in the Resident Macros file.
  13. */
  14.  
  15. // special code to allow direct execution
  16. FUNC main()
  17. {
  18.  EXTERN(PREF_GET("mac1"),main(1));
  19.  RETURN;
  20. }
  21.  
  22.  
  23. /***********************************************************************/
  24. /*                   Start of Startup Macros                           */
  25. /***********************************************************************/
  26.  
  27. FUNC startup()
  28. {
  29.  SHARED STR _RMAC;
  30.  _RMAC = "1034";                // don't remove this //
  31.  
  32. // Filetypes to be sent as "text" with Text/MacBinary mode:
  33.  PREF_SET("stxt","TEXTttroEPSF");
  34. // Filetypes to be sent as "binary" with Text/MacBinary mode:
  35.  PREF_SET("sbin","JPEGJFIFGIFfTIFFMPEGZIVUTARFPDF ????");
  36. // All other filestypes use "macbinary" with Text/MacBinary mode.
  37.  
  38. // leave this code unchanged
  39.  RESIDENT("",0,#KeyAccess+#LibAccess);
  40.  RETURN;
  41. }
  42.  
  43.  
  44. /***********************************************************************/
  45. /*                   Start of Keyboard Macros                          */
  46. /***********************************************************************/
  47.  
  48.  
  49. //
  50. // COMMAND+OPTION+¥: Attempt to launch URL
  51. //
  52. FUNC ked_092a()
  53. {
  54.  INT anc,ext,win,err,len;
  55.  STR url;
  56.  
  57.  win = WIN_ACTIVE(0);
  58.  anc = IO_GETPOS(win);
  59.  ext = IO_GETSEL(win);
  60.  
  61.  IF (anc > ext) {
  62.   IO_SETPOS(win,ext);
  63.   len = anc-ext;
  64.  } ELSE {
  65.   IO_SETSEL(win,anc);
  66.   len = ext-anc;
  67.  }
  68.  url = IO_READ(win,len);
  69.  IO_SETPOS(win,anc);
  70.  IO_SETSEL(win,ext);
  71.  
  72.  err = -1;
  73.  IF (url != "") { err = IC_LAUNCH("",url) }
  74.  IF (err == -1) { WIN_NOTE(1,"No URL Selected") }
  75.  IF (err < -1) { WIN_NOTE(1,"Unable to Parse URL") }
  76.  RETURN(err);
  77. }
  78.  
  79.  
  80. //
  81. // COMMAND+OPTION+/: Insert a pathname/filename into a document
  82. //
  83. FUNC ked_092C()
  84. {
  85.  STR file = FN_OPEN(0,"Type Name","????");
  86.  IF (file != "") { UI_TYPE(file) }
  87.  RETURN;
  88.  
  89.  
  90. //
  91. // COMMAND+OPTION+I: Set Default Receive Folder
  92. //
  93. FUNC key_0922()
  94. {
  95.  STR path = FN_PATH(4,"Set Recv");
  96.  IF (path != "") {
  97.   FN_SETPATH(4,path);
  98.  }
  99.  RETURN;
  100. }
  101.  
  102.  
  103. //
  104. // COMMAND+OPTION+D: Keyboard Dialing List
  105. //
  106. FUNC key_0902()
  107. {
  108.  STR file = FN_OPEN(5,"Connect","SRVSSRVL");
  109.  IF (file != "") {
  110.   UI_OPEN(file);
  111.   UI_CLICK("Connect:2");
  112.  }
  113.  RETURN;
  114. }
  115.  
  116.  
  117. //
  118. // COMMAND+OPTION+L: Reconnect to Prior Service
  119. //
  120. FUNC key_0925()
  121. {
  122.  IF (WIN_TYPE(WIN_ACTIVE(0)) == "REVW") {
  123.   UI_OPEN(SES_GET(WIN_ACTIVE(0),"PATH"));
  124.   UI_CLICK("Retry");
  125.  }
  126.  RETURN;
  127. }
  128.  
  129.  
  130. //
  131. // COMMAND+OPTION+R: Start Protocol Receive from Keyboard
  132. //
  133. FUNC ktr_090F()
  134. {
  135.  SESSION STR recv_proto;
  136.  IF (recv_proto != "") {
  137.   UI_MENU("Online:Receive:"+recv_proto);
  138.  }
  139.  RETURN;
  140. }
  141.  
  142.  
  143. //
  144. // COMMAND+OPTION+S: Start Protocol Send from Keyboard
  145. //
  146. FUNC ktr_0901()
  147. {
  148.  SESSION STR send_proto;
  149.  IF (send_proto != "") {
  150.   UI_MENU("Online:Send:"+send_proto);
  151.  }
  152.  RETURN;
  153. }
  154.  
  155.  
  156. //
  157. // COMMAND+OPTION+Z: reload global macros
  158. //
  159. FUNC key_0906()
  160. {
  161.  main(1);
  162.  RETURN;
  163. }
  164.  
  165.  
  166. //
  167. // PgUp: Scroll Up a Page (terminal window only)
  168. //
  169. FUNC ktr_0074()
  170. {
  171.  UI_SET("vscroll", "<");
  172.  RETURN;
  173. }
  174.  
  175. //
  176. // PgDn: Scroll Down a Page (terminal window only)
  177. //
  178. FUNC ktr_0079()
  179. {
  180.  UI_SET("vscroll", ">");
  181.  RETURN;
  182. }
  183.  
  184. //
  185. // Home: Move to Start of Window (terminal window only)
  186. //
  187. FUNC ktr_0073()
  188. {
  189.  UI_SET("vscroll", "0");
  190.  RETURN;
  191. }
  192.  
  193. //
  194. // End: Move to End of Window (terminal window only)
  195. //
  196. FUNC ktr_0077()
  197. {
  198.  UI_SET("vscroll", "100");
  199.  RETURN;
  200. }
  201.  
  202. //
  203. // Ins: Scroll Up a Line (terminal window only)
  204. //
  205. FUNC ktr_0072()
  206. {
  207.  UI_SET("vscroll", "-");
  208.  RETURN;
  209. }
  210.  
  211. //
  212. // Del: Scroll Down a Line (terminal window only)
  213. //
  214. FUNC ktr_0075()
  215. {
  216.  UI_SET("vscroll", "+");
  217.  RETURN;
  218. }
  219.  
  220.  
  221. /***********************************************************************/
  222. /*                   Start of Library Macros                           */
  223. /***********************************************************************/
  224.  
  225.  
  226. //
  227. // Send text directly to emulation module
  228. //
  229. FUNC ses_emul(arg1)
  230. {
  231.  IF (IS_STR(arg1)) {
  232.   IO_PRINT(WIN_FIND(SES_GET(0,"TERM WINDOW NAME"),"TERM"),arg1);
  233.  } ELSE {
  234.   IO_PRINT(WIN_FIND(SES_GET(arg1,"TERM WINDOW NAME"),"TERM"),ARGV(2));
  235.  }
  236.  RETURN;
  237. }
  238.  
  239.  
  240. //
  241. // Display initial connect info in terminal window
  242. //
  243. FUNC ses_rate()
  244. {
  245.  INT tc;
  246.  STR lc,rt;
  247.  
  248.  tc = WIN_FIND(SES_GET(0,"TERM WINDOW NAME"));
  249.  lc = SES_GET(0,"LAST CONNECT");
  250.  STR_PARSE(lc,"%*s(%s)",rt);
  251.  IO_PRINTF(tc,"^m%s^m^j^m^j",rt);
  252.  RETURN;
  253. }
  254.  
  255.  
  256. //
  257. // glue code to link to ProTERM Messenger
  258. //
  259. FUNC ses_msgr()
  260. {
  261.  STR home;
  262.  
  263.  home = FN_WHERE(SES_GET(#TermChan,"PATH"));
  264.  EXTERN(home+"Interface",con_auto(home));
  265.  EXTERN(home+":!Messenger",main(1));
  266.  RETURN;
  267. }
  268.  
  269.  
  270. //
  271. // setup keyboard send/receive protocol
  272. //
  273. FUNC key_xfer(str proto)
  274. {
  275.  SESSION STR send_proto;
  276.  SESSION STR recv_proto;
  277.  send_proto = recv_proto = proto;
  278.  RETURN;
  279. }
  280.  
  281. //
  282. // setup keyboard receive protocol
  283. //
  284. FUNC key_recv(STR proto)
  285. {
  286.  SESSION STR recv_proto;
  287.  recv_proto = proto;
  288.  RETURN;
  289. }
  290.  
  291. //
  292. // setup keyboard send protocol
  293. //
  294. FUNC key_send(STR proto)
  295. {
  296.  SESSION STR send_proto;
  297.  send_proto = proto;
  298.  RETURN;
  299. }
  300.  
  301.  
  302. /***********************************************************************/
  303. /*                              Array Macros                           */
  304. /***********************************************************************/
  305.  
  306.  
  307. //
  308. // create a numeric array
  309. //
  310. // entry: size=size of array (0 to 1000 elements)
  311. // exit: returns the array as a string
  312. //
  313. FUNC array_num(INT size)
  314. {
  315.  IF ((size < 0) || (size > 1000)) {
  316.   ERROR("Array Size Out of Range (0..1000)");
  317.  }
  318.  RETURN(STR_LONG(size)+STR_LONG(4)+STR_REPEAT("^0",(size+1)*4));
  319. }
  320.  
  321. //
  322. // create a string array
  323. //
  324. // entry: size=size of array (0 to 1000 elements)
  325. // exit: returns the array as a string
  326. //
  327. FUNC array_str(INT width, INT size)
  328. {
  329.  IF ((width < 1) || (width > 1024)) {
  330.   ERROR("Array Width Out of Range (1..1024)");
  331.  }
  332.  IF ((size < 0) || (size > 1000)) {
  333.   ERROR("Array Size Out of Range (0..1000)");
  334.  }
  335.  
  336.  IF (width < 4) { width = 4 }
  337.  width = width + 1;
  338.  RETURN(STR_LONG(size)+STR_LONG(width)+STR_REPEAT("^0",(size+1)*width));
  339. }
  340.  
  341. //
  342. // return array size information
  343. //
  344. // entry: array=the array, dimin: 0=return width (bytes), 1=return size (items)
  345. // exit: returns the size information
  346. //
  347. FUNC array_size(STR array, INT dimin)
  348. {
  349.  INT x;
  350.  
  351.  x = SWITCH(dimin) {
  352.   CASE 0: {
  353.    x = NUM_LONG(STR_MID(array,4));
  354.    IF (x <= 4) { 1 } ELSE { x-1 };
  355.   }
  356.   CASE 1: {
  357.    NUM_LONG(array);
  358.   }
  359.   DEFAULT: {
  360.    0;
  361.   }
  362.  }
  363.  RETURN(x);
  364. }
  365.  
  366. //
  367. // get a value from an array
  368. //
  369. // entry: array=the array, index=the element index
  370. // exit: returns the value of the element at the specified index
  371. //
  372. FUNC array_get(STR array, INT index)
  373. {
  374.  INT width;
  375.  STR value;
  376.  
  377.  IF ((index < 0) || (index > NUM_LONG(array))) {
  378.   ERROR("Array Index Out of Range");
  379.  }
  380.  
  381.  IF ((width = NUM_LONG(STR_MID(array,4,4))) == 4) {
  382.   RETURN(NUM_LONG(STR_MID(array,8+index*4,4)));
  383.  }
  384.  
  385.  value = STR_MID(array,8+index*width,width);
  386.  RETURN(STR_MID(value,1,NUM_BYTE(value)));
  387. }
  388.  
  389. //
  390. // set a value within an array
  391. //
  392. // entry: array=the array, value=the new value, index=the element index
  393. // exit: returns an updated array with the changed value
  394. //
  395. FUNC array_set(STR array, value, INT index)
  396. {
  397.  INT width;
  398.  
  399.  IF ((index < 0) || (index > NUM_LONG(array))) {
  400.   ERROR("Array Index Out of Range");
  401.  }
  402.  
  403.  IF ((width = NUM_LONG(STR_MID(array,4,4))) == 4) {
  404.    RETURN(STR_LEFT(array,8+index*4)+
  405.           STR_LONG(value)+
  406.           STR_MID(array,8+(index+1)*4));
  407.  }
  408.  
  409.  RETURN(STR_LEFT(array,8+index*width)+
  410.         STR_BYTE(STR_LEN(value))+
  411.         STR_REPEAT(value,width-1)+
  412.         STR_MID(array,8+(index+1)*width));
  413. }
  414.  
  415. //
  416. // add a new value within an array (extend bounds)
  417. //
  418. // entry: array=the array, value=the new value, index=the element index
  419. // exit: returns an updated array with the changed value
  420. //
  421. FUNC array_add(STR array, value)
  422. {
  423.  INT width,index;
  424.  
  425.  index = NUM_LONG(STR_MID(array,0,4));
  426.  width = NUM_LONG(STR_MID(array,4,4));
  427.  
  428.  IF (width == 4) {
  429.   RETURN(STR_LONG(index+1)+
  430.          STR_LONG(width)+
  431.          STR_MID(array,8)+
  432.          STR_LONG(value));
  433.  }
  434.  
  435.  RETURN(STR_LONG(index+1)+
  436.         STR_LONG(width)+
  437.         STR_MID(array,8)+
  438.         STR_BYTE(STR_LEN(value))+
  439.         STR_REPEAT(value,width-1));
  440. }
  441.  
  442.  
  443. /***********************************************************************/
  444. /*                            Glue Functions                           */
  445. /***********************************************************************/
  446.  
  447. FUNC ui_new(STR file)
  448. {
  449.  IF (IS_FILE(file)) { RETURN(-1) }
  450.  F_CREATE(file);
  451.  UI_OPEN(file);
  452.  RETURN(0);
  453. }
  454.  
  455. FUNC ui_open(STR file)
  456. {
  457.  STR type = F_EXISTS(file);
  458.  IF (type != "") {
  459.   UI_CMD('cmd=menu call="#Sub:Open" file=&%*2s type=@%s',file,type);
  460.  }
  461.  RETURN(0);
  462. }
  463.  
  464. FUNC ui_close(STR file)
  465. {
  466.  INT win = WIN_FILE(file);
  467.  UI_CMD('cmd=msg wind=%d msg=CLOS',win);
  468.  RETURN(0);
  469. }
  470.  
  471. FUNC ui_save(STR file)
  472. {
  473.  INT win = WIN_FILE(file);
  474.  UI_CMD('cmd=file #save wind=%d',win);
  475.  RETURN(0);
  476. }
  477.  
  478. FUNC ui_get(STR item)
  479. {
  480.  RETURN(D_GET(WIN_ACTIVE(0),item));
  481. }
  482.  
  483. FUNC ui_set(STR item, STR value)
  484. {
  485.  INT win,ret;
  486.  STR type;
  487.  
  488.  win = WIN_ACTIVE(0);
  489.  ret = D_SET(win,item,value);
  490.  type = WIN_TYPE(win);
  491.  IF ((type == "FS2*") || (type == "FS3*") || (type == "FS4*")) {
  492.   IF (STR_UPPER(item) == "FILE") { WIN_WAIT(win) }
  493.  }
  494.  RETURN(ret);
  495. }
  496.  
  497. FUNC ui_click(STR item)
  498. {
  499.  RETURN(D_SET(WIN_ACTIVE(0),item,"~"));
  500. }
  501.  
  502. FUNC ui_equiv(STR menu, STR key)
  503. {
  504.  IF (key == "") { key = " " }
  505.  RETURN(MM_KEY(menu,key));
  506. }
  507.  
  508. FUNC ui_connect(STR file,INT count,INT sync)
  509. {
  510.  STR result;
  511.  
  512.  IF (F_EXISTS(file) != "SRVS") { RETURN("") }
  513.  result = UI_CMD("cmd=connect file=&%*2s count=%d %s",file,count,
  514.   (IF (sync) { "#SYNC" } ELSE { "" }),
  515.  );
  516.  RETURN("");
  517. }
  518.  
  519.